package com.wondertek.poms.search.controller;

import com.wondertek.poms.common.vo.ResultBean;
import com.wondertek.poms.dao.po.PublishLog;
import com.wondertek.poms.search.service.IPublishLogESService;
import com.wondertek.poms.search.vo.PublishLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author chenjijiang
 * @description
 */
@RestController
@RequestMapping("publish-log-es")
public class PublishLogESController {
	@Autowired
	private IPublishLogESService iPublishLogESService;

	/**
	 * @param publishLogVo 发布历史查询vo
	 * @param page         页数
	 * @param start        开始的第一条数
	 * @param rows         记录数
	 * @return 查询结果
	 */
	@GetMapping("list")
	public ResultBean list(PublishLogVo publishLogVo,
	                       @RequestParam(defaultValue = "1") int page,
	                       @RequestParam(defaultValue = "0") int start,
	                       @RequestParam(defaultValue = "20") int rows) {
		Map<String, Object> map = new HashMap<>();
		Long count = iPublishLogESService.getCount(publishLogVo.getPrdContId(), publishLogVo.getContId(),
				publishLogVo.getPubStartTime(), publishLogVo.getPubEndTime(), publishLogVo.getPubStatus(), publishLogVo.getPrdInfoId(),
				publishLogVo.getCreateUserName());
		List<PublishLog> list = iPublishLogESService.getPubsPage(start, rows, publishLogVo.getPrdContId(), publishLogVo.getContId(),
				publishLogVo.getPubStartTime(), publishLogVo.getPubEndTime(), publishLogVo.getPubStatus(), publishLogVo.getPrdInfoId(),
				publishLogVo.getCreateUserName());
		map.put("count", count);
		map.put("data", list);
		return ResultBean.ok(map);
	}



}
